﻿using System;
using System.Configuration;
using System.Web;
using System.Web.UI.WebControls;

namespace BLL
{
    public class UserLogoService
    {
        public static string FileUploads(FileUpload fileProduct, string url)
        {
            if (!fileProduct.HasFile)
            {
                return "出错";

            }
            try
            {
                var picSavePath = HttpContext.Current.Server.MapPath("~") + @"\UpLoad\Userlogo\";

                string urlimg = DateTime.Now.ToString("hhmmss") + fileProduct.FileName;
                var picPath = picSavePath + urlimg;
                fileProduct.SaveAs(picPath);
                var picUrl = ConfigurationManager.AppSettings["PicDomain"] + urlimg;
                return picUrl;
            }
            catch
            {
                return "出错";
            }
        }

        public static string GetUserLogo(string imgUrl)
        {
            var picName = imgUrl.Substring(imgUrl.LastIndexOf("/"));
            return "/Upload/UserLogo/" + picName;
        }
    }
}